#ifndef POWERTRAY_H
#define POWERTRAY_H

#include <QObject>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QTimer>
#include <QLabel>
#include <QWidgetAction>
#include <QDBusInterface>
#include <QTimer>

class PowerTray:public QObject{
    Q_OBJECT
public:
    explicit PowerTray(QObject *parent = 0);
    ~PowerTray();
    void setVisible(bool visible);
    bool isVisible() const;
signals:
    void exitRequired();
    void showSettingsRequested();
private slots:
    void onExit();
    void updateBatteryStatus();
    void onShowSettings();
    void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
    void onBatteryPropertiesChanged(QString interface, QVariantMap changedProps, QStringList invalidatedProps);
private:
    void creatTrayMenu();
    void setupTrayIcon();
    bool checkBatteryExists();
    QString getBatteryStatus();
    QString getBatteryIconName(int percentage,const QString &status);
    int getBatteryCapacity() const;
    QSystemTrayIcon *trayIcon;
    QDBusInterface *upowerInterface;
    QDBusInterface *batteryInterface;
    bool batteryExists;
    QMenu *trayMenu;
    QTimer *updateTimer;
};






#endif // POWERTRAY_H
